package tobsn.locationcalendar.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class DBOpenHelper extends SQLiteOpenHelper {

	private static final int DATABASE_VERSION = 1;
	private static final String DATABASE_NAME = "locationcalendar";
    public static final String NOTIFICATION_TABLE_NAME = "notification";
    public static final String ROW_ID = "_id";
    public static final int ROW_ID_INT = 0;
    public static final String NOTIFICATION_COLUMN_TEXT = "text";
    public static final int TEXT_INT = 1;
    public static final String NOTIFICATION_COLUMN_LATITUDE = "latitude";
    public static final int LATITUDE_INT = 2;
    public static final String NOTIFICATION_COLUMN_LONGITUDE = "longitude";
    public static final int LONGITUDE_INT = 3;
    
    private static final String EXPENSE_TABLE_CREATE =
                "CREATE TABLE " + NOTIFICATION_TABLE_NAME + " (" +
                ROW_ID + " integer primary key autoincrement, " +
                NOTIFICATION_COLUMN_TEXT + " text not null, " +
                NOTIFICATION_COLUMN_LATITUDE + " integer not null, "+
                NOTIFICATION_COLUMN_LONGITUDE + " integer not null);";
	
    
    public DBOpenHelper(Context context){
    	super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }
    
	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(EXPENSE_TABLE_CREATE);

	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		Log.w(DBOpenHelper.class.getName(),
				"Upgrading database from version " + oldVersion + " to "
						+ newVersion + ", which will destroy all old data");
		db.execSQL("DROP TABLE IF EXISTS " + NOTIFICATION_TABLE_NAME);
		onCreate(db);
	}

}
